package com.tensquare.recruit.controller;
import com.tensquare.recruit.pojo.Recruit;
import com.tensquare.recruit.service.RecruitService;
import entity.PageResult;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
/**
 * 控制器层
 * @author Administrator
 *
 */
@RestController
@CrossOrigin
@RequestMapping("/recruit")
public class RecruitController {

	@Autowired
	private RecruitService recruitService;

	/**
	 * 查询状态为2并以创建日期降序排序，查询前6条记录
	 * @return
	 */
	@RequestMapping(value = "/search/recommend", method = RequestMethod.GET)
	public Result recommend() {
		List<Recruit> list = recruitService.findTop6ByStateOrderByCreatetime();
		return new Result(true, StatusCode.OK, "查询成功", list);
	}

	/**
	 * 最新职位列表
	 * @return
	 */
	@RequestMapping(value = "/search/newlist",method= RequestMethod.GET)
	public Result newlist(){
		List<Recruit> list = recruitService.findTop6ByStateNotOrderByCreatetimeDesc();
		return new Result(true, StatusCode.OK, "查询成功", list);
	}
}